import 'dart:async';

import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/message/message_config.dart';
import 'package:ls_work/model/patrol/patrol_task_model.dart';
import 'package:ls_work/sql/protral/offline_submit_patrol_entity.dart';

import 'offline_task_upload_service.dart';

class OfflineTaskRecordViewModel extends BaseListViewModel<OfflineSubmitPatrolData>{
  OfflineTaskRecordViewModel(BuildContext context) : super(context);

  var model = PatrolTaskModel();
  @override
  Future<List<OfflineSubmitPatrolData>> requestListData() async {
    return await model.getLocalRecord();
  }


  @override
  void onCreated() {
    super.onCreated();
    requestRefresh(showAni: false);

  }

  void startUpload(){
    showCupertinoDialog(context: context, builder: (context){
      return UploadTaskDialog(list: listItems,);
    },barrierDismissible: false);
  }

  @override
  void receiveMessage(SendMessageEvent event) {
    super.receiveMessage(event);
    if(event.msgCode==MessageConfig.REFRESH_PATROL){
      requestRefresh(showAni: false);
    }
  }

}